<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>在线充值 - __SITENAME__</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <link type="text/css" href="__DOMAINURL____WEBSITEDIR____BAOFENG__/css/public.css" rel="stylesheet" />
    <link href="__DOMAINURL____WEBSITEDIR____PLUGINS__/css/fonts/iconfont.css" rel="stylesheet" type="text/css" />
    <script src="__DOMAINURL____WEBSITEDIR____PLUGINS__/css/fonts/iconfont.js"></script>
    <script src="__DOMAINURL____WEBSITEDIR____PLUGINS__/jQuery/jquery-2.2.3.min.js"></script>
    <script src="__DOMAINURL____WEBSITEDIR____BAOFENG__/js/vue.min.js"></script>
    <script src="__DOMAINURL____WEBSITEDIR____BAOFENG__/js/public.js?v=81"></script>
    <script src="__DOMAINURL____WEBSITEDIR____BAOFENG__/js/layer/layer.js"></script>
    <link type="text/css" href="__DOMAINURL____WEBSITEDIR____BAOFENG__/js/layer/need/layer.css" rel="stylesheet" />
    <link type="text/css" href="__DOMAINURL____WEBSITEDIR____BAOFENG__/css/chongzhi.css" rel="stylesheet" />
    <script src="__DOMAINURL____WEBSITEDIR____BAOFENG__/js/chongzhi.js"></script>

    <style>
	body{
		padding-bottom:35px;
	}
        .icon {
            height: 1em;
            margin-top:0px;
            fill: currentColor;
            overflow: hidden;
        }
    </style>
</head>
<body>

<div id="recharge">
    <!--<div class="ad">
            <img src="__DOMAINURL____WEBSITEDIR____BAOFENG__/img/cz_ad.png" />
        </div>-->
    <div class="prompt">
        当日剩于可充值额度：{!pdata.UseRechargeMoney!}元
    </div>
    <div class="uk-block uk-block-default toaccount">充值金额：<h4 class="text-red" >{!money!}</h4>（入金收取<span class="text-red">{!pdata.ChargingFee!}%</span>手续费）到帐金额：<h4 class="text-red" >{!money-toaccount!}</h4></div>
    <div class="select_money uk-block uk-block-default">
        <span>选择充值金额（元）</span>
        <select-btns-component></select-btns-component>
    </div>

    <div class="pay uk-block uk-block-default">
        <select-bank-btns-component></select-bank-btns-component>
        <div class="row card_number">
            <a class="btn btn-primary" @click="commit()">确认</a>
            <div style="display:none;">* 每笔上限{!pdata.EachMaximumRechargeAmount!}元，每日上限{!pdata.SingledayMaximumRechargeAmount!}元</div>
            <div style="display:none;">* 每笔下限{!pdata.SingleMinimumAmountRecharge!}元</div>
        </div>
    </div>
    <div class="foot_safety">
        <div>
            <i class="iconfont icon-anquan" style="background:transparent;color:#0688e9"></i>
            <span>保障您的资金安全</span>
        </div>
		<a style="display:block;text-align:center;margin-top:125px;color: #157afb;text-decoration: underline;" href="__DOMAINURL____WEBSITEDIR__/user/suggest" class="line">投诉&建议</a>
        <!--<hr>-->
    </div>
</div>

<script type="text/javascript">
    var global = {$init_date};
    var sub = true;//防止重复提交
    Vue.config.delimiters = ['{!', '!}'];
    var vue = new Vue({
        el: '#recharge',
        data: {
            pdata: global,
            money:global.moneylist[0],
            toaccount:0,//到帐金额
            cz_bank:null,//选中银行
        },
        events:{
            'select_money_change':function(msg){
                this.money=msg.money;
                this.toaccount =parseFloat(this.money*(this.pdata.ChargingFee/100)).toFixed(2);
            },
            'select_bank_change':function(msg){
                this.cz_bank=msg.bank;
            }
        },
        methods: {
            init: function () {
                var default_bank = null;
                if (global.banks.length > 0) {
                    for(var i=0; i<global.banks.length; i++) {
                        if (global.banks[i].isUse == 1) {
                            default_bank = global.banks[i];
                            break;
                        }
                    }
                }
                this.cz_bank = default_bank;

                this.$broadcast('select_btns_init', { btns: global.moneylist});
                this.$broadcast('select_banks_init', { banks: global.banks, default_bank:default_bank });
                this.toaccount =parseFloat(this.money*(this.pdata.ChargingFee/100)).toFixed(2);
            },
            commit:function(){
                if (!sub) {
                    return;
                }
                sub = false;
                if (this.cz_bank == null) {
                    alert("请选择一个充值银行");
                    sub = true;
                    return;
                } else if(this.cz_bank.isUse != 1) {
                    alert("该充值通道暂时关闭");
                    sub = true;
                    return;
                }
                check_chongzhi(this.money, this.cz_bank);
            }
        },
    });
    vue.init();


    function check_chongzhi(money, cz_bank) {
        if (money < cz_bank.min_money) {
            alertMsg("该充值通道最底充值金额为：" + cz_bank.min_money  + "元");
            sub = true;
            return;
        }
        if (cz_bank.max_money > 0 && money >= cz_bank.max_money) {
            alertMsg("该充值通道最高充值金额为：" + cz_bank.max_money  + "元");
            sub = true;
            return;
        }
        $.ajax({
            type: 'POST',
            dataType : 'json',
            url:'checkchongzhi' ,
            data: {money:money},
            success: function(json){
                if(json.status=="ok") {
                    if (cz_bank.subUrl == "button") {
                        window.location.href="pay?money="+money+"&pbank="+cz_bank.value+"&type="+cz_bank.type;
                    } else {
                        window.location.href=cz_bank.subUrl;
                    }
                } else{
                    alertMsg(json.msg);
                }
                sub = true;
            }
        });
    }

</script>

<div class="loader">
    <div class="act">
        <div class="spinner">
            <div class="double-bounce1"></div>
            <div class="double-bounce2"></div>
        </div>
    </div>
    <div class="bg"></div>
</div>

</body>
</html>